/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header$
 * $Id$
 * $Author$
 * $Date$
 * $Revision$
 */
package com.elancom.framework.commons.asm;

import java.lang.instrument.Instrumentation;

import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;

/**
 * @author elancom
 * @date 2012-7-28
 */
public class CW implements Opcodes {
	public static void main(String[] args) {
		ClassWriter cw = new ClassWriter(0);
		cw.visit(V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, "pkg/Comparable", null, "java/lang/Object", new String[] { "java/lang/Runnable" });
		cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "LESS", "I", null, new Integer(-1)).visitEnd();
		cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "compareTo", "(Ljava/lang/Object;)I", null, null).visitEnd();
		cw.visitEnd();

		byte[] buf = cw.toByteArray();

		MyClassLoader classLoader = new MyClassLoader();
		Class<?> c = classLoader.defineClass("pkg.Comparable", 0, buf.length, buf);
		System.out.println(c);
		
		new CW();
		
		System.out.println(ClassWriter.COMPUTE_FRAMES);
	}

	public static void premain(String agentArgs, Instrumentation inst) {
		System.out.println("====>");
	}
}
